<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        // 当文档加载完毕 然后就执行{}里面的代码
        window.onload = function () {

            // 通过id获取div对象
            var oDiv1 = document.getElementById("div1");
            // [object HTMLDivElement]
            alert(oDiv1);
            
        }
    </script>
</head>

<body>


    <div class="box" id="div1">哈哈哈哈哈哈</div>



</body>

</html>